/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 *Truth: I Believe in Spring Brother~
 */

package electsys;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author t
 * Created 2010-7-1  20:38:42
 * Last Modified 2010-7-1  20:38:42
 *
 */
public class LessonInfo {
    
    public String id = "";
    public String name = "";
    public String classroom = "";
    public String week = "";
    public List<Integer> weeks = null;
    public int dayOfWeek = 0;
    public String startTime = "";
    public String endTime ="";
    public String teacherName = "";
    public String point = "";
    public String notes = "";

    public LessonInfo(){
        
    }

    public LessonInfo(String na, String cl, List<Integer> wee,int dow, String st, String et) {
        this.setInfo1(na, cl, wee, dow, st, et);
    }

    public void setInfo1(String na, String cl, List<Integer> wee,int dow, String st, String et) {
        this.name = na;
        this.classroom = cl;
        this.weeks = wee;
        this.dayOfWeek = dow;
        this.startTime = st;
        this.endTime = et;
    }

    public String getMainInfo() {
        String tmp = this.name+"(" +this.week+")"+String.valueOf(dayOfWeek+1)+"["+this.classroom+"]"+this.startTime+"-"+this.endTime;
        return tmp;
    }

    public static boolean earlier(String s1, String s2) {
        return true;
    }

    public List<String> getFormatedStartTime(List<Calendar> cals, String timezone) {
        List<String> times = new ArrayList();
        Date date = null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        for (int i = 0; i < this.weeks.size(); i++) {
            date = cals.get(this.weeks.get(i)-1).getTime();
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);
            cal.add(Calendar.DAY_OF_YEAR, this.dayOfWeek);
            date = cal.getTime();
            String time = new String(sdf.format(date) + "T" + this.startTime + ":00" + timezone);
            times.add(time);
        }
        return times;
    }

     public List<String> getFormatedEndTime(List<Calendar> cals, String timezone) {
        List<String> times = new ArrayList();
        Date date = null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        for (int i = 0; i < this.weeks.size(); i++) {
            date = cals.get(this.weeks.get(i)-1).getTime();
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);
            cal.add(Calendar.DAY_OF_YEAR, this.dayOfWeek);
            date = cal.getTime();
            String time = new String(sdf.format(date) + "T" + this.endTime + ":00" + timezone);
            times.add(time);
        }
        return times;
    }
}
